<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>vue html demo</title>
    <script src="./lib/vue-2.4.0.js"></script>
    <script src="./lib/vue-router-3.0.1.js"></script>

</head>

<body>
    <div id="app">
        <!-- 如果在路由中 使用查询字符串 给路由传递参数 不需要修改path -->
        <!-- <router-link to="/login/12/zs">登录</router-link>
                <router-link to="/register">zhuce</router-link> -->
        <router-link to="/demo">demo</router-link>
        <router-view></router-view>
    </div>

    <template id="demo">
        <div>
            <h1>demo</h1>
            <router-link to="/demo/login">登录</router-link>
            <router-link to="/demo/register">注册</router-link>
        <router-view></router-view>

        </div>
    </template>

    <!-- <template id="login">
        <div>
            <h1>这是login</h1>

        </div>
    </template>

    <template id="register">
        <div>
            <h1>这是register</h1>
        </div>
    </template> -->

    <script>
        var demo = {
            template: '#demo' //'<h1>这是login</h1>',
            // created() {
            //     console.log(this.$route.params)
            // },
        }

        var login = {
            template: '<h1>login</h1>' // '#login'
        }

        var register = {
            template:  '<h1>register</h1>'// '#register'
        }

        var router = new VueRouter({
            routes: [{
                    path: '/demo',
                    component: demo,
                    children: [{
                            path: 'login',
                            component: login
                        },
                        {
                            path: 'register',
                            component: register
                        }
                    ]
                },
                // {path: '/demo/login', component:login },
                // {path: '/demo/register', component:register },
            ]
        })

        var vm = new Vue({
            el: '#app',
            data: {

            },
            methods: {

            },
            router
        })
    </script>
</body>

</html>